package pojo;


import Info.SystemEnum;

import java.util.HashSet;
import java.util.Set;

public class Contrast {
    private Set<Car> set;

    public Contrast() {
        set = new HashSet<>();
    }

    public Contrast(Set<Car> set) {
        this.set = set;
    }

    public Set<Car> getSet() {
        if(set.size()==0) return null;
        return set;
    }

    public boolean setAdd(Car car){
        if(car==null){
            System.out.println(getClass()+"\tsetAdd\t"+ SystemEnum.ERROR_REPEAT.toString());
            return false;
        }else{
            set.add(car);
            System.out.println(getClass()+"\tsetAdd\t"+ SystemEnum.SUCCESS.toString());
            return true;
        }
    }

    public boolean setDelete(Car car){
        if(set.contains(car)){
            set.remove(car);
            System.out.println(getClass()+"\tsetDelete\t"+ SystemEnum.SUCCESS.toString());
            return true;
        }
        System.out.println(getClass()+"\tsetAdd\t"+ SystemEnum.ERROR_MATCH.toString());
        return false;
    }
    public boolean setFind(Car car){
        if(car==null) return false;
        else{
            if(set.contains(car)){
                System.out.println(getClass()+"\tsetFind\t"+ SystemEnum.SUCCESS.toString());
                return true;
            }else{
                System.out.println(getClass()+"\tsetFind\t"+ SystemEnum.ERROR_MATCH.toString());
                return false;
            }
        }
    }
    @Override
    public String toString() {
        return "Contrast{" +
                "set=" + set +
                '}';
    }
}
